package com.biboheart.adapter.express.support;

import com.biboheart.adapter.express.actuator.ActuatorRegistry;
import com.biboheart.adapter.express.actuator.ActuatorService;
import com.biboheart.adapter.support.enums.InstructEnum;

public class DefaultActuatorService extends GenericActuatorService {
    private static volatile DefaultActuatorService sharedInstance;

    public DefaultActuatorService() {
        addDefaultActuator(this);
    }

    public static ActuatorService getSharedInstance() {
        DefaultActuatorService as = sharedInstance;
        if (null == as) {
            synchronized (DefaultActuatorService.class) {
                as = sharedInstance;
                if (as == null) {
                    as = new DefaultActuatorService();
                    sharedInstance = as;
                }
            }
        }
        return as;
    }

    public static void addDefaultActuator(ActuatorRegistry actuatorRegistry) {
        actuatorRegistry.addActuator(InstructEnum.INSTRUCT_CONVERT.code(), new ConvertActuator());
        actuatorRegistry.addActuator(InstructEnum.INSTRUCT_CONCAT.code(), new ConcatActuator());
        actuatorRegistry.addActuator(InstructEnum.INSTRUCT_SUBSTRING.code(), new SubstringActuator());
        actuatorRegistry.addActuator(InstructEnum.INSTRUCT_REPLACE.code(), new ReplaceActuator());
        actuatorRegistry.addActuator(InstructEnum.INSTRUCT_SPLIT.code(), new SplitActuator());
        actuatorRegistry.addActuator(InstructEnum.INSTRUCT_TIME.code(), new TimeActuator());
        actuatorRegistry.addActuator(InstructEnum.INSTRUCT_TIMESTAMP.code(), new TimestampActuator());
        actuatorRegistry.addActuator(InstructEnum.INSTRUCT_DATETIME.code(), new DatetimeActuator());
        actuatorRegistry.addActuator(InstructEnum.INSTRUCT_ROUND.code(), new RoundActuator());
        actuatorRegistry.addActuator(InstructEnum.INSTRUCT_BINARY.code(), new BinaryActuator());
        actuatorRegistry.addActuator(InstructEnum.INSTRUCT_MAX.code(), new MaxActuator());
        actuatorRegistry.addActuator(InstructEnum.INSTRUCT_MIN.code(), new MinActuator());
        actuatorRegistry.addActuator(InstructEnum.INSTRUCT_DEF.code(), new DefActuator());
        actuatorRegistry.addActuator(InstructEnum.INSTRUCT_CASE.code(), new CaseActuator());
        actuatorRegistry.addActuator(InstructEnum.INSTRUCT_WHEN.code(), new WhenActuator());
        actuatorRegistry.addActuator(InstructEnum.INSTRUCT_ELSE.code(), new ElseActuator());
    }
}
